# Load Data
MFQ20 <- read.table(file.choose(), header = TRUE)

# Make Party and Ideology Variables
MFQ20$Party.cat <- NA
MFQ20$Party.cat[MFQ20$Party <= 3] <- "Democrat"
MFQ20$Party.cat[MFQ20$Party == 4] <- "Independent"
MFQ20$Party.cat[MFQ20$Party >= 5] <- "Republican"

MFQ20$Ideol.cat <- NA
MFQ20$Ideol.cat[MFQ20$Ideol <= 3] <- "Liberal"
MFQ20$Ideol.cat[MFQ20$Ideol == 4] <- "Moderate"
MFQ20$Ideol.cat[MFQ20$Ideol >= 5] <- "Conservative"

# Create MFT Scales
MFQ20$HarmTotal.1 <- ((MFQ20$Harm1 + MFQ20$Harm2 + MFQ20$Harm3) - 3)/15
MFQ20$FairTotal.1 <- ((MFQ20$Fair1 + MFQ20$Fair2 + MFQ20$Fair3) - 3)/15
MFQ20$IngroupTotal.1 <- ((MFQ20$Ingroup1 + MFQ20$Ingroup2 + MFQ20$Ingroup3 +
                            MFQ20$Ingroup4) - 4)/20
MFQ20$AuthTotal.1 <- ((MFQ20$Auth1 + MFQ20$Auth2 + MFQ20$Auth3) - 3)/15
MFQ20$PureTotal.1 <- ((MFQ20$Pure1 + MFQ20$Pure2 + MFQ20$Pure3 +
                         MFQ20$Pure4) - 4)/20

# Using VGAM package for Tobit Mods
library(VGAM)

# Democrats first
MFQ20.D <- subset(MFQ20, Party.cat == "Democrat")

Tobit1.Harm.D <- vglm(HarmTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.D)
summary(Tobit1.Harm.D)

Tobit1.Fair.D <- vglm(FairTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.D)
summary(Tobit1.Fair.D)

Tobit1.Ingroup.D <- vglm(IngroupTotal.1 ~ Treatment, 
                         subset = c(Treatment != "Ideol"), 
                         tobit(Upper = 1, Lower = 0), 
                         data = MFQ20.D)
summary(Tobit1.Ingroup.D)

Tobit1.Auth.D <- vglm(AuthTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.D)
summary(Tobit1.Auth.D)

Tobit1.Pure.D <- vglm(PureTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.D)
summary(Tobit1.Pure.D)


# Now Republicans
MFQ20.R <- subset(MFQ20, Party.cat == "Republican")

Tobit1.Harm.R <- vglm(HarmTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Lower = 0, Upper = 1), 
                      data = MFQ20.R)
summary(Tobit1.Harm.R)

Tobit1.Fair.R <- vglm(FairTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.R)
summary(Tobit1.Fair.R)

Tobit1.Ingroup.R <- vglm(IngroupTotal.1 ~ Treatment, 
                         subset = c(Treatment != "Ideol"), 
                         tobit(Upper = 1, Lower = 0), 
                         data = MFQ20.R)
summary(Tobit1.Ingroup.R)

Tobit1.Auth.R <- vglm(AuthTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.R)
summary(Tobit1.Auth.R)

Tobit1.Pure.R <- vglm(PureTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Ideol"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.R)
summary(Tobit1.Pure.R)


# Liberals
MFQ20.L <- subset(MFQ20, Ideol.cat == "Liberal")

Tobit1.Harm.L <- vglm(HarmTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.L)
summary(Tobit1.Harm.L)

Tobit1.Fair.L <- vglm(FairTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.L)
summary(Tobit1.Fair.L)

Tobit1.Ingroup.L <- vglm(IngroupTotal.1 ~ Treatment, 
                         subset = c(Treatment != "Party"), 
                         tobit(Upper = 1, Lower = 0), 
                         data = MFQ20.L)
summary(Tobit1.Ingroup.L)

Tobit1.Auth.L <- vglm(AuthTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.L)
summary(Tobit1.Auth.L)

Tobit1.Pure.L <- vglm(PureTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.L)
summary(Tobit1.Pure.L)


# Conservatives
MFQ20.C <- subset(MFQ20, Ideol.cat == "Conservative")

Tobit1.Harm.C <- vglm(HarmTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.C)
summary(Tobit1.Harm.C)

Tobit1.Fair.C <- vglm(FairTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.C)
summary(Tobit1.Fair.C)

Tobit1.Ingroup.C <- vglm(IngroupTotal.1 ~ Treatment, 
                         subset = c(Treatment != "Party"), 
                         tobit(Upper = 1, Lower = 0), 
                         data = MFQ20.C)
summary(Tobit1.Ingroup.C)

Tobit1.Auth.C <- vglm(AuthTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.C)
summary(Tobit1.Auth.C)

Tobit1.Pure.C <- vglm(PureTotal.1 ~ Treatment, 
                      subset = c(Treatment != "Party"), 
                      tobit(Upper = 1, Lower = 0), 
                      data = MFQ20.C)
summary(Tobit1.Pure.C)

